'use strict';
/**
 * weibo strategy
 * https://github.com/xinbenlv/passport-weibo
 */
var passport = require('passport'),
    WeiboStrategy = require('passport-weibo').Strategy,
    config = require('../config');
    // users = require('../../app/controllers/users.server.controller');

module.exports = function() {
    passport.use(new WeiboStrategy({
            clientID: config.strategies.weibo.clientId, // WEIBO_CLIENT_ID,
            clientSecret: config.strategies.weibo.clientSecret, // WEIBO_CLIENT_SECRET,
            callbackURL: config.strategies.weibo.callbackUrl //"http://127.0.0.1:3000/auth/weibo/callback"
        },
        function(accessToken, refreshToken, profile, done) {
            User.findOrCreate({ weiboId: profile.id }, function (err, user) {
                return done(err, user);
            });
        }
    ));
};
